import { defineStore } from 'pinia'
export const settingStore = defineStore('setting', {
    state: () => ({
        displayMethod: 'card',
        videoFolders: [] as any,
        sort: 'asc',
        theme: 'light',
        '--back': '#ffffff',
        '--text': '#1e1e1e',
        '--shadow': '#82828257',
    }),
    // 开始数据持久化
    persist: true,
    actions: {
        changeTheme() {
            if (this.theme === 'dark') {
                this.theme = 'light'
                this['--back'] = '#ffffff'
                this['--text'] = '#1e1e1e'
                this['--shadow'] = '#82828257'
            } else {
                this.theme = 'dark'
                this['--back'] = '#1e1e1e'
                this['--text'] = '#ffffff'
                this['--shadow'] = '#a6a6a68f'
            }
            this.setGlobal()
        },
        setGlobal() {
            document.documentElement.style.setProperty('--back', this['--back'])
            document.documentElement.style.setProperty('--text', this['--text'])
            document.documentElement.style.setProperty('--shadow', this['--shadow'])
        }
    },
})
